package form.ui.component.Select.Option {
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	import form.ui.component.Select.Option;
	import form.ui.core.Frame;

	public class SelectedOption extends Frame {
		public static const FONT_SIZE:int = 11;
		public static const FONT_COLOR:int = 0x000000;
		public static const TEXT_INDENT:int = 4;
		public static const MARGIN_TOP:int = 1;
		
		
		public static const DISABLED_FONT_COLOR:int = 0x999999;
		
		protected var textField:TextField = new TextField();
		
		public function SelectedOption() {
			super();
			
			SelectedOption.defineTextField(this.textField);
			
			this.addChild(this.textField);
			
			this.textField.y = SelectedOption.MARGIN_TOP;
		}
		
		public function set text(value:String):void {
			this.textField.text = value;
		}
		
		public function get text():String {
			return this.textField.text;
		}
		
		public function enable():void {
			this.textField.textColor = SelectedOption.FONT_COLOR;
		}
		
		public function disable():void {
			this.textField.textColor = SelectedOption.DISABLED_FONT_COLOR;
		}
		
		protected static function defineTextField(textField:TextField):void {
			textField.mouseEnabled = false;
			textField.selectable = false;
			
			textField.width = Option.WIDTH;
			textField.defaultTextFormat = SelectedOption.textFormat;
			
			textField.textColor = Option.FONT_COLOR;
			textField.background = false;
		}
		
		protected static function get textFormat():TextFormat {
			var format:TextFormat = new TextFormat();
			
			format.font = Option.FONT_FAMILY;
			format.size = SelectedOption.FONT_SIZE;
			format.indent = SelectedOption.TEXT_INDENT;
			
			return format;
		}
	}
}